package org.openems.osa;

import java.awt.Dimension;
import java.awt.FlowLayout;

import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.scene.paint.Color;
import javax.swing.JFrame;
import framework.Client;
import framework.DomainService;

public class OsaClient implements Client {

	@Override
	public String getTitle() {
		return "iOSA";
	}

	@Override
	public void initialize(final DomainService service) {
		if (isJavafx()) {
			Platform.runLater(new Runnable() {
				@Override
				public void run() {
					createUiJavafx(service);
				}
			});
		}
		else {
			
		}
	}

	private boolean isJavafx() {
		return true;
	}

	private void createUiJavafx(DomainService service) {
		OSAID id = OSAID.get();
		
		UiFactory factory = new SwingFactory();
		
		IFrame mainFrame = factory.createFrame();
		mainFrame.setSize(new Dimension(800, 640));
		mainFrame.setVisible(true);
		mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		mainFrame.setLayout(new FlowLayout());
		mainFrame.add(new MyComboBox(id.VBW, service, factory.createComboBox()).getComponent());
		mainFrame.add(new MyComboBox(id.VBW, service, factory.createComboBox()).getComponent());
		
		mainFrame.doLayout();
	}
}
